home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4193 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. From: zodiac@darkness.gun.de (Ralph Seichter)
  2. Subject: Re: SAS/C fopen("foo","a") -- is this a bug?
  3. Date: Thu, 15 Feb 96 12:13:43 CET
  4. Message-ID: <zp547aaCHJYPZ1@da23.darkness.gun.de>
  5. X-ZC-PGP-KEY-AVAIL: 
  6. Path: tim.xenologics.com!darkness.gun.de
  7. X-ZC-F-TO: Matthias Meixner
  8. X-Newsreader: Zodiac's Point 37.208 [REGISTERED 0001] via Connectline-CLMSortin 2.25
  9. Newsgroups: comp.sys.amiga.programmer
  10. X-Gateway: ZConnect DA darkness.gun.de [Connectline/AmigaOS]
  11. References: <zpfaa8aCCygGZ1@da23.darkness.gun.de> <4feh2j$7im@castle.nando.net> <zpfaa8aCGrYkZ1@da23.darkness.gun.de> <4fs8t3$12hp@rs18.hrz.th-darmstadt.de>
  12. Content-Type:  text/plain; charset=ISO-8859-1
  13. Content-Transfer-Encoding:  8bit
  14. Mime-Version:  1.0
  15.  
  16. On 14.02.96, meixner@rbg.informatik.th-darmstadt.de (Matthias Meixner) wrote
  17.  
  18. > : You mean you can actually write into a write protected file?
  19. >
  20. > There are even worse things in V39: you can change the date of a file
  21. > even if the disk is locked with "lock":
  22.  
  23. Steve Krueger has made me aware of a bug in the ram-handler, which I can
  24. easily (and unfortunately) reproduce with Kickstart 40.68. Compile the
  25. following test program, and then do:
  26.  
  27.    1> date >foo
  28.    1> protect foo r
  29.    1> test3
  30.  
  31. On a hard disk, -1 is returned to indicate a write error, as expected. But
  32. if you do the same in your RAM disk, Write() will actually write into the
  33. write protected file "foo". That's really shocking!
  34.  
  35. ----------8<----------8<----------8<----------8<----------8<----------
  36. /* test3.c */
  37.  
  38. #include <proto/dos.h>
  39.  
  40. int main(void)
  41. {
  42.     BPTR file;
  43.  
  44.     if (file = Open("foo", MODE_READWRITE))
  45.     {
  46.         (void)Seek(file, 0, OFFSET_END);
  47.         Printf("Write() returned %ld\n", Write(file, "bar\n", 4));
  48.         Close(file);
  49.     }
  50.     else
  51.         Printf("Open() failed\n");
  52.     return(0);
  53. }
  54. ----------8<----------8<----------8<----------8<----------8<----------
  55.  
  56.     -Ralph
  57. -- 
  58. "Fⁿr manche ist es ein Stⁿck Schei▀e, fⁿr andere
  59.   die lΣngste Praline der Welt." (Walter Moers)
  60.